From bb84d3f346ad09eff14c062d848e6d413f37a329 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Tue, 16 Sep 2014 15:41:38 +0000 Subject: [PATCH] blanket replace of xstrdup(QString.toUtf8().data()) to avoid potential deep copies. --- gpsbabel/an1.cc | 4 ++-- gpsbabel/cet_util.cc | 2 +- gpsbabel/gbfile.cc | 2 +- gpsbabel/gpx.cc | 2 +- gpsbabel/html.cc | 2 +- gpsbabel/tmpro.cc | 2 +- gpsbabel/util.cc | 6 +++--- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gpsbabel/an1.cc b/gpsbabel/an1.cc index 2b6b55482..6ce63cb05 100644 --- a/gpsbabel/an1.cc +++ b/gpsbabel/an1.cc @@ -814,14 +814,14 @@ Write_One_AN1_Waypoint(const Waypoint* wpt) if (rec->type == 0x12) { /* image */ if (wpt->icon_descr.contains(":\\")) { - rec->image_name = xstrdup(wpt->icon_descr.toUtf8().data()); + rec->image_name = xstrdup(CSTR(wpt->icon_descr)); rec->height = -244; rec->width = -1; } } if (!rec->image_name && !wpt->icon_descr.isNull()) { // FIXME: WTH? - char* t = xstrdup(wpt->icon_descr.toUtf8().data()); + char* t = xstrdup(CSTR(wpt->icon_descr)); FindIconByName(t, &rec->guid); xfree(t); } diff --git a/gpsbabel/cet_util.cc b/gpsbabel/cet_util.cc index 3122b9a9b..e357287e3 100644 --- a/gpsbabel/cet_util.cc +++ b/gpsbabel/cet_util.cc @@ -423,7 +423,7 @@ cet_convert_string(const QString& str) // FIXME: this is really weird. Since cet_convert_string wants to free // its argument (!) we make a duplicate just to satisfy that kind of goofy // requirement. - return cet_convert_string(xstrdup(str.toUtf8().data())); + return cet_convert_string(xstrdup(CSTR(str))); } /* cet_convert_waypt: internal used within cet_convert_strings process */ diff --git a/gpsbabel/gbfile.cc b/gpsbabel/gbfile.cc index 7a05780c7..c6d5c9d44 100644 --- a/gpsbabel/gbfile.cc +++ b/gpsbabel/gbfile.cc @@ -1272,7 +1272,7 @@ gbfputpstr(const char* s, gbfile* file) int gbfputpstr(const QString& s, gbfile* file) { - const char* t = xstrdup(s.toUtf8().data()); + const char* t = xstrdup(CSTR(s)); int r = gbfputpstr(t, file); xfree(t); return r; diff --git a/gpsbabel/gpx.cc b/gpsbabel/gpx.cc index 5030f3304..a991785db 100644 --- a/gpsbabel/gpx.cc +++ b/gpsbabel/gpx.cc @@ -803,7 +803,7 @@ xml_parse_time(const QString& dateTimeString) int off_sign = 1; char* offsetstr = NULL; char* pointstr = NULL; - char* timestr = xstrdup(dateTimeString.toUtf8().data()); + char* timestr = xstrdup(CSTR(dateTimeString)); offsetstr = strchr(timestr, 'Z'); if (offsetstr) { diff --git a/gpsbabel/html.cc b/gpsbabel/html.cc index 35e76638b..8655cdaab 100644 --- a/gpsbabel/html.cc +++ b/gpsbabel/html.cc @@ -143,7 +143,7 @@ html_disp(const Waypoint* wpt) if (html_encrypt) { hint = rot13(wpt->gc_data->hint); } else { - hint = xstrdup(wpt->gc_data->hint.toUtf8().data()); + hint = xstrdup(CSTR(wpt->gc_data->hint)); } gbfprintf(file_out, "

Hint: %s

\n", hint); xfree(hint); diff --git a/gpsbabel/tmpro.cc b/gpsbabel/tmpro.cc index 19ef9b499..a7048c886 100644 --- a/gpsbabel/tmpro.cc +++ b/gpsbabel/tmpro.cc @@ -209,7 +209,7 @@ tmpro_waypt_pr(const Waypoint* wpt) if (wpt->HasUrlLink()) { // Yes, it's lame to allocate/copy here. UrlLink link = wpt->GetUrlLink(); - l = xstrdup(link.url_.toUtf8().data()); + l = xstrdup(CSTR(link.url_)); } gbfprintf(file_out, "new\t%.6s\t%.80s\t%08.6f\t%08.6f\t\t\t%.2f\t%d\t%d\t%.128s\n", CSTRc(shortname), diff --git a/gpsbabel/util.cc b/gpsbabel/util.cc index ada0c5d89..076f0bc87 100644 --- a/gpsbabel/util.cc +++ b/gpsbabel/util.cc @@ -1168,7 +1168,7 @@ strlower(char* src) char* rot13(const QString& s) { - char* result = xstrdup(s.toUtf8().data()); + char* result = xstrdup(CSTR(s)); char* cur = result; int flip = 1; while (cur && *cur) { @@ -1406,8 +1406,8 @@ strip_nastyhtml(const QString& in) char* returnstr, *sp; char* lcstr, *lcp; - sp = returnstr = xstrdup(in.toUtf8().data()); - lcp = lcstr = strlower(xstrdup(in.toUtf8().data())); + sp = returnstr = xstrdup(CSTR(in)); + lcp = lcstr = strlower(xstrdup(CSTR(in))); while (lcp = strstr(lcstr, ""), NULL != lcp) { sp = returnstr + (lcp - lcstr) ; /* becomes */ -- 2.30.2